<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../resources/multiple-fields-ax-aria-attributes.js"></script>
</head>
<body>
<input id=test type="time" step="0.001" value="12:34:56.789" aria-label="TestLabel" title="TestTitle">
<script>
function keyDown(key, modifiers)
{
    if (!window.eventSender)
        return;
    eventSender.keyDown(key, modifiers);
}

var testInput = document.getElementById("test");

test(function(t) {
    testInput.focus();
    assert_equals(focusedElementDescription(),
                  'Hours TestLabel, --, "12", TestTitle, intValue:12, range:1-12');
    keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'Minutes TestLabel, --, "34", TestTitle, intValue:34, range:0-59');
    keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'Seconds TestLabel, --, "56", TestTitle, intValue:56, range:0-59');
    keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'Milliseconds TestLabel, ---, "789", TestTitle, intValue:789, range:0-999');
    keyDown('\t');
    assert_equals(focusedElementDescription(),
                  'AM/PM TestLabel, --, "PM", TestTitle, intValue:2, range:1-2');
}, 'Non-empty value');

test(function(t) {
    keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'AM/PM TestLabel, --, "", TestTitle, intValue:0, range:1-2');
    keyDown('\t', ['shiftKey']);
    keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'Milliseconds TestLabel, ---, "", TestTitle, intValue:0, range:0-999');
    keyDown('\t', ['shiftKey']);
    keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'Seconds TestLabel, --, "", TestTitle, intValue:0, range:0-59');
    keyDown('\t', ['shiftKey']);
    keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'Minutes TestLabel, --, "", TestTitle, intValue:0, range:0-59');
    keyDown('\t', ['shiftKey']);
    keyDown('Backspace');
    assert_equals(focusedElementDescription(),
                  'Hours TestLabel, --, "", TestTitle, intValue:0, range:1-12');
}, 'Empty value');

</script>
</body>
</html>
